
/**
 * copyright(c) 2013 www.jiongshibaoliao.com, All Rights Reserved.
 * project: jiongshibaoliao 
 * author: 曾帅
 * date: 2014-1-9 下午05:05:28
 * version: v1.0
 */

package com.jiongshibaoliao.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.jiongshibaoliao.common.mybatis.Page;
import com.jiongshibaoliao.common.mybatis.PageBean;
import com.jiongshibaoliao.dao.ArticleDao;
import com.jiongshibaoliao.exception.JiongException;
import com.jiongshibaoliao.mapper.ArticleMapper;
import com.jiongshibaoliao.mapper.BaseMapper;
import com.jiongshibaoliao.model.Article;

/**
 * @project jiongshibaoliao
 * @author 曾帅 
 * @version 1.0
 * @date 2014-1-9 下午05:05:28   
 */

@Repository
public class ArticleDaoImpl extends BaseDaoImpl implements ArticleDao {
	
	@Autowired
	public ArticleMapper articleMapper;
	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-9 下午05:06:01
	 * @see com.jiongshibaoliao.dao.ArticleDao#getArticlePageList(com.jiongshibaoliao.common.mybatis.PageBean, com.jiongshibaoliao.model.Article)
	 */
	@Override
	public Page getArticlePageList(PageBean pageBean, Map<String, Object> map) {
		List<Article> articlelist = (List<Article>) articleMapper.getArticlePageList(pageBean, map);
		return new Page(articlelist, pageBean);
	}

	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-10 下午09:37:47
	 * @see com.jiongshibaoliao.dao.impl.BaseDaoImpl#delete(long)
	 */
	@Override
	public void delete(long id) throws JiongException {
		throw new JiongException("无权执行此操作！");
	}
	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-10 下午09:17:03
	 * @see com.jiongshibaoliao.dao.impl.BaseDaoImpl#setBaseMapper(com.jiongshibaoliao.mapper.BaseMapper)
	 */
	@Override
	public BaseMapper getMapper() {
		return articleMapper;
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-9 下午02:56:27
	 * @see com.jiongshibaoliao.dao.ArticleDao#getUNAuditCount(java.lang.String, java.lang.String)
	 */
	@Override
	public int getUNAuditCount(String clientIp, Long userId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("clientIp", clientIp);
		map.put("userId", userId);
		
		return articleMapper.getUNAuditCount(map);
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-9 下午02:56:27
	 * @see com.jiongshibaoliao.dao.ArticleDao#getUNAuditRandom(java.lang.String, java.lang.String, long)
	 */
	@Override
	public Article getUNAuditRandom(String clientIp, Long userId, long few) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("clientIp", clientIp);
		map.put("userId", userId);
		map.put("few", few);
		
		return articleMapper.getUNAuditRandom(map);
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-13 下午02:28:02
	 * @see com.jiongshibaoliao.dao.ArticleDao#getMoodMostArticlePageList(com.jiongshibaoliao.common.mybatis.PageBean)
	 */
	@Override
	public Page getMoodMostArticlePageList(PageBean pageBean) {
		List<Article> articlelist = (List<Article>) articleMapper.getMoodMostArticlePageList(pageBean);
		return new Page(articlelist, pageBean);
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-13 下午04:30:06
	 * @see com.jiongshibaoliao.dao.ArticleDao#getAuditArticleCount()
	 */
	@Override
	public int getAuditArticleCount() {
		return articleMapper.getAuditArticleCount();
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-13 下午04:30:06
	 * @see com.jiongshibaoliao.dao.ArticleDao#getAuditArticleRandom(long)
	 */
	@Override
	public Article getAuditArticleRandom(long few) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("few", few);
		
		return articleMapper.getAuditArticleRandom(few);
	}
	
}
